# 加载文档
# pip install doctran==0.0.14
with open("letter.txt", encoding="utf-8") as f:
    content = f.read()

# print(content)

import os
api_key = os.getenv("OPENAI_API_KEY")
api_base = os.getenv("OPENAI_API_BASE")

OPENAI_MODEL = "gpt-3.5-turbo"
OPENAI_TOKEN_LIMIT = 8000

from doctran import Doctran

doctrans = Doctran(
    openai_api_key=api_key,
    openai_model=OPENAI_MODEL,
    openai_token_limit=OPENAI_TOKEN_LIMIT,
)
documents = doctrans.parse(content=content)

#总结文档
summary = documents.summarize(token_limit=100).execute()
print(summary.transformed_content)

#翻译一下文档
translation = documents.translate(language="chinese").execute()
print(translation.transformed_content)

#精炼文档，删除除了某个主题或关键词之外的内容，仅保留与主题相关的内容
refined = documents.refine(topics=["marketing","Development"]).execute()
print(refined.transformed_content)